package test1.www.lagou.app;

import test1.www.lagou.dao.Dao;
import test1.www.lagou.entity.Account;

import java.sql.SQLException;
import java.util.Scanner;

/**
 * @Author : liuchangling
 * @Descrition :
 * @Date： Created in 5:47 下午 2021/5/10
 */
public class test {
    public static Scanner scanner = new Scanner(System.in);
    public static Dao dao = new Dao();
    public static Account account;

    public static void main(String[] args) {

        System.out.println("请输入您的卡号：");
        String cardOrigin = scanner.next();

        // 1.查询账户信息，以判断余额
        try {
            account=dao.selectBalance(cardOrigin);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        System.out.println("请输入您要转账的金额：");
        float num=scanner.nextFloat();
        if(num>account.getBalance()){
            System.out.println("您的余额不足，即将退出！");
        }

        // 2.转账功能、记录功能
        System.out.println("请输入您要转账的卡号：");
        String card=scanner.next();
        dao.transfer(cardOrigin,num,card);

        // 3.查询价格高于2000元，生产日期是2019年之前的所有手机
        try {
            dao.findPhone();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        // 4.查询白色手机

        try {
            dao.findPhoneWhite();
        } catch (SQLException e) {
            e.printStackTrace();
        }


    }
}
